
// number of items
var NUMBER_OF_ITEMS = 1000;


silobox({
    title: "Which is the best loop?",
    description: "Tests different ways of iterating over a set of 1000 items.",
    reps: 10,
    iterations: 1000,
	testdelay: 2000,
    tests: [
	    {
	        title: "Normal for loop",
			description: "Traditional 'for' loop looking up the length each time.",
	        code: function() {

				var items = { length: NUMBER_OF_ITEMS };

				for (var i = 0; i < items.length; i++) {
					do_something(i);
				}

	        }
	    },
	    {
	        title: "Normal for loop with cached length",
			description: "Traditional 'for' loop with cached length",
	        code: function() {

				var items = { length: NUMBER_OF_ITEMS };

				for (var i = 0, l = items.length; i<l; i++) {
					do_something(i);
				}

	        }
	    },
	    {
	        title: "Backwards loop",
			description: "Starting at the end of the list and working backwards, the loop-test and counting expression are combined.",
	        code: function() {

				var items = { length: NUMBER_OF_ITEMS };

				for (var i = items.length; i--;) {
					do_something(i);
				}

	        }
	    },
	    {
	        title: "Backwards while loop",
			description: "Starting at the end of the list and working backwards, the variables are setup outside the loop and one statement acts as the loop-test and counting expression.",
	        code: function() {

				var items = { length: NUMBER_OF_ITEMS };
				var i = items.length;
				while (i--) {
					do_something(i - 1);
				}

	        }
	    }
    ]
});